package edu.thu.studio.ormdesigner.outline.command;

import edu.thu.studio.ormdesigner.common.AbstractCommand;
import edu.thu.studio.ormdesigner.model.ORMModel;
import edu.thu.studio.ormdesigner.model.domain.Domain;
import edu.thu.studio.ormdesigner.model.domain.DomainSet;

public class CreateDomainCommand extends AbstractCommand {
    
    private DomainSet domains;
    
    private Domain domain;
    
    public CreateDomainCommand(ORMModel model, Domain domain) {
        this.domains = model.getDomains();
        this.domain = domain;
    }
    
    /**
     * {@inheritDoc}
     */
    @Override
    protected void doExecute() {
        domains.addObject(domain);
        domains.refresh();
    }
    
    /**
     * {@inheritDoc}
     */
    @Override
    protected void doUndo() {
        domains.remove(domain);
        domains.refresh();
    }
}
